package com.aaa;

import com.aaa.config.MyRuleConfiguration;
import com.aaa.rule.MyRandomRule;
import com.netflix.loadbalancer.IRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Hello world!
 *
 */
@SpringBootApplication
@MapperScan("com.aaa.mapper")
// 表示哪个服务集群使用我们的自定义负载均衡策略
@RibbonClient(value = "shop-product" , configuration = MyRuleConfiguration.class)
@EnableFeignClients
public class Order9001
{
    public static void main( String[] args )
    {
        SpringApplication.run(Order9001.class,args);
    }
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
    //@Bean
    public IRule setRule(){
        return new MyRandomRule();
    }
}
